home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15689 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1021 b 

  1. Path: news.panther.net!nemesis!hammy!not-for-mail
  2. From: gordon@sneaky.lerctr.org (Gordon Burditt)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: beginner needs help about langtons's ant
  5. Date: 20 Apr 1996 22:54:51 -0500
  6. Organization: What organization?
  7. Message-ID: <4lcbib$1em@hammy.lonestar.org>
  8. References: <4lbrsi$4o@usc.edu>
  9. NNTP-Posting-Host: news.hammy.lonestar.org
  10.  
  11. >        char a[100][100];
  12. ...
  13. >int i,j;
  14. >for(i=0;i<=100;i++);
  15. >for(j=0;j<=100;j++);
  16. >a[i][j]=e;} 
  17. ***ERROR*** subscript out of range.  You probably don't want those
  18. semicolons on the for loops.  As-is, this code is equivalent to:
  19.  
  20.     int    i,j;
  21.     i = 100;
  22.     j = 100;
  23.     a[100][100] = e;
  24.  
  25. and since a is dimensioned 100 by 100, the highest legal subscripts
  26. are a[99][99].
  27.  
  28. >           void            regular(int i, int j)
  29. >    {
  30. >        char            a[100][100], b;
  31. >        
  32. >        if (a[i][j] == NULL)
  33.  
  34. You haven't initialized this array, which is NOT the same as the a
  35. declared earlier, so why are you testing values in it?
  36.  
  37.                     Gordon L. Burditt
  38.                     sneaky.lerctr.org!gordon
  39.